package com.lihao.sam.reslover;

import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ExceptionResolver implements HandlerExceptionResolver {

    @Override
    public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
        ex.printStackTrace();
        //1.实例化 数据和页面对象
        ModelAndView view=new ModelAndView();
        //设置统一页面
        view.setViewName("/error.html");
        return view;
    }
}
